// elementui 版本的 myalert
const myalert = {};
myalert.success = function(msg) {
  window._vm.$message({
    message: msg,
    type: "success"
  });
};
myalert.confirmFail = function(msg) {
  window._vm.$alert(msg, {
    confirmButtonText: window._vm.lang == "zh" ? "确定" : "Confirm",
    type: "warning"
  });
};
myalert.alert = function(msg) {
  return new Promise(resolve => {
    window._vm.$alert(msg, window._vm.$t("lang.提示"), {
      showClose: false,
      confirmButtonText: window._vm.lang == "zh" ? "确定" : "Confirm",
      callback: action => {
        resolve();
      }
    });
  });
};
myalert.confirmSuccess = function(msg) {
  window._vm.$alert(msg, {
    confirmButtonText: window._vm.lang == "zh" ? "确定" : "Confirm",
    type: "success"
  });
};
myalert.fail = function(msg) {
  window._vm.$message.error(msg, window._vm.lang == "zh" ? "提示" : "Tip", {
    confirmButtonText: window._vm.lang == "zh" ? "确定" : "Confirm",
    cancelButtonText: window._vm.lang == "zh" ? "取消" : "Cancel",
    type: "warning"
  });
};
myalert.confirm = function(msg) {
  return window._vm
    .$confirm(msg, window._vm.lang == "zh" ? "提示" : "Tip", {
      confirmButtonText: window._vm.lang == "zh" ? "确定" : "Confirm",
      cancelButtonText: window._vm.lang == "zh" ? "取消" : "Cancel",
      type: "warning"
    })
    .then(res => {
      return true;
    })
    .catch(e => {
      return false;
    });
  // return window._vm.$alert(msg, '提示', {
  //     confirmButtonText: '确定',
  //     cancelButtonText: '取消',
  // }).then(res => {
  //     $(".el-message-box__wrapper .el-message-box__message").text(msg)
  //     return res
  // })
};
//带有输入的提示 options seemore http://element.eleme.io/#/zh-CN/component/message-box
myalert.prompt = function(msg, options) {
  return window._vm.$prompt(msg, window._vm.lang == "zh" ? "提示" : "Tip", {
    confirmButtonText: window._vm.lang == "zh" ? "确定" : "Confirm",
    cancelButtonText: window._vm.lang == "zh" ? "取消" : "Cancel",
    inputPattern: options.inputPattern,
    inputValidator: options.inputValidator,
    inputValue: options.inputValue,
    inputErrorMessage: options.inputErrorMessage || "格式不正确"
  });
};
export default myalert;
